layui.use(['jquery','layer','table','form'],function(){
    var $=layui.jquery;
    var layer=layui.layer;
    var form = layui.form;

    $('#cancel').click(function () {
        var layer = parent.layer;
        layer.close(layer.index)
    });
    //课程分类赋值
    $.ajax({
        url: '/examine/getCourseClass',
        dataType: 'json',
        type: 'post',
        success: function (data) {
            var courseClass = data.data;
            for (var i = 0; i < courseClass.length; i++) {
                $('#courseClass').append('<option value="' + courseClass[i].name + '" >' + courseClass[i].name + '</option>')
            }
            form.render('select');
        }
    });
    form.on('submit(sub)',function () {
        var courseId = $("input[name=courseId]").val();
        var courseNprice = $("input[name=courseNprice]").val();
        var createName = $("input[name=createName]").val();
        var courseClass = $("#courseClass option:selected").text();
        var courseName = $("input[name=courseName]").val();
        var coursePrimary = $("input[name=coursePrimary]").val();
        $.ajax({
            url:'/examine/searchCourse',
            type:'post',
            dataType:'json',
            data:{'courseId':courseId,'courseNprice':courseNprice,'createName':createName,'courseClass':courseClass,'courseName':courseName,'coursePrimary':coursePrimary,'type':2},
            success:function (data) {
                parent.advancedSearch(data.data);
                var layer = parent.layer;
                layer.close(layer.index);
            }
        })
        return false;
    });
})